<template>
	<cover-view class="overlay">
    <u-tabbar
        height="120"
        icon-size="56"
        mid-button
        v-show="showTabbar"
        :activeColor="tabbarStyle.st_color"
        :inactiveColor="tabbarStyle.ust_color"
        :list="tabbarList2">
    </u-tabbar>
  </cover-view>
</template>

<script>
	import { mapGetters } from 'vuex'
	export default {
		data() {

			return {
				currentRoute: '',
        tabbarList2: [
          {
            "text": "首页",
            "status": 1,
            "pagePath": "/pages/index/index",
            "selectedIconPath": "http://114.55.130.31/uploads/images/20241026/202410262115340787f2894.png",
            "iconPath": "http://114.55.130.31/uploads/images/20241026/202410262115350ccae1422.png",
            "midButton": 0
          },
          {
            "text": "逛一逛",
            "status": 1,
            "pagePath": "/pages/review/review",
            "selectedIconPath": "http://114.55.130.31/uploads/images/20241026/20241026211534df9f38905.png",
            "iconPath": "http://114.55.130.31/uploads/images/20241026/20241026211535bff242421.png",
            "midButton": 0
          },
          {
            "text": "发现",
            "status": 1,
            "pagePath": "/pages/find/find",
            "selectedIconPath": "http://114.55.130.31/uploads/images/20241026/20241026211534f09af6574.png",
            "iconPath": "http://114.55.130.31/uploads/images/20241026/20241026211534f09af6574.png",
            "midButton": true
          },
          {
            "text": "头条",
            "status": 1,
            "pagePath": "/pages/headline/headline",
            "selectedIconPath": "http://114.55.130.31/uploads/images/20241026/2024102621153553b0e5906.png",
            "iconPath": "http://114.55.130.31/uploads/images/20241026/20241026211534752305855.png",
            "midButton": 0
          },
          {
            "text": "我的",
            "status": 1,
            "pagePath": "/pages/user/user",
            "selectedIconPath": "http://114.55.130.31/uploads/images/20241026/2024102621153585ac48507.png",
            "iconPath": "http://114.55.130.31/uploads/images/20241026/20241026211534a67884839.png",
            "midButton": 0
          }
        ]
      }
		},
		mounted() {
			const currentPages = getCurrentPages()
			const currentPage = currentPages[currentPages.length - 1]
			this.currentRoute = currentPage.route
		},
		computed: {
			tabbarStyle() {
				return this.appConfig.navigation_setting || {}
			},
			tabbarList() {
				const tabbar = this.appConfig.navigation_menu || []
        console.log('this.appConfig.navigation_menu',this.appConfig.navigation_menu)
				console.log(this.cartNum )
				let list =  tabbar.filter((item) => item.status == 1).map((item) => {
					return {
						iconPath: item.iconPath,
						selectedIconPath: item.selectedIconPath,
						text: item.name,
            midButton: item.midButton === 1 ? true : false,
						count: item.page_path == 'pages/shop_cart/shop_cart' ? this.cartNum : 0,
						pagePath: '/' + item.page_path,
					}
				})
        console.log('list',list)
        return list
			},
			showTabbar() {
        return true
				const current = this.tabbarList.findIndex((item) => {
					return item.pagePath === '/' + this.currentRoute
				})
				return current >= 0
			},
			...mapGetters(['cartNum']),
		}
	}
</script>
<style>
.overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 9999999; /* 设置为比视频组件更高的层级 */
}
</style>
